aboutsummaryrefslogtreecommitdiff
path: root/src/routes/grocery/[id]
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-10-18 22:02:02 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-10-18 22:02:02 +0200
commit0685e9ece66fbcb09c9457027cf7bb2107cc0171 (patch)
treef6dabadf2dcf55f2847a48ada2e03e491f017dcc /src/routes/grocery/[id]
parentc3c61894d2b119ae424bac605d4b3099e0b674e5 (diff)
refactor: inject the database into services via a constructor
Pilot on the categories service: a CategoriesService class holds the Drizzle handle, and services/index.ts wires the real instance once for the server while tests build their own on an in-memory database. AppDatabase moves from groceries.ts to db/types.ts.
Diffstat (limited to 'src/routes/grocery/[id]')
-rw-r--r--src/routes/grocery/[id]/+page.server.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/routes/grocery/[id]/+page.server.ts b/src/routes/grocery/[id]/+page.server.ts
index 232568c..0f386f3 100644
--- a/src/routes/grocery/[id]/+page.server.ts
+++ b/src/routes/grocery/[id]/+page.server.ts
@@ -2,7 +2,7 @@ import { error, fail, redirect } from '@sveltejs/kit';
import { db } from '$lib/server/db';
import { groceries, categories } from '$lib/server/db/schema';
import { eq } from 'drizzle-orm';
-import { loadAll as loadCategories } from '$lib/server/services/categories';
+import { categoriesService } from '$lib/server/services';
import {
loadForGrocery,
add as addRef,
@@ -40,7 +40,7 @@ export const load: PageServerLoad = async ({ params, url }) => {
: [null];
const refs = await loadForGrocery(id);
- const cats = await loadCategories();
+ const cats = await categoriesService.loadAll();
const from = url.searchParams.get('from') || '/';
return {